<script type="text/javascript">
$(function () {
	$.ajaxSetup({cache: false});
	$('#editOrganForm').find("input:checkbox, input:radio").not('input.ibtn').uniform();
});

function saveOrgan_organ() {
	var parm = $('#editOrganForm').serialize();
	var url = create_url('organ-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功!');
				sys_load_handle('organ');
			} else {
				sys_warning('操作失败!');
			}
		}
	});
}

function selectParent_organ(code) {
	var url = create_url('organ-aidInit');
	var parm = {'id':'pc', 'name':'pn', 'code':code};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'400px', height:'600px', open:true});
}
</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>

<form id="editOrganForm">
	<table class="table boo-table table-content" style="margin-left:20px;">
		<#if organ?? && organ.pc?? && organ.pc != 0>
		<tr>
			<td class="table-left">上级机构</td>
			<td>
<!-- 				<div class="input-append"> -->
					<input type="hidden" name="pc" id="pc" value="${(organ.pc)!''}" />
					<input class="form-control" type="text" name="pn" id="pn" value="${(organ.pn)!''}" readonly="readonly">
					<!-- <button class="btn btn-xs btn-primary" type="button" onclick="javascript: selectParent(${(organ.code)!(organ.pc)!''});"><i class="icon-search"></i></button>
					<button class="btn btn-xs btn-danger" type="button" onclick="javascript: $('#pc').val(''); $('#pn').val('');"><i class="icon-remove"></i></button> -->
<!-- 				</div> -->
			</td>
		</tr>
		</#if>
		<tr>
			<td class="table-left" style="width:100px;">名称</td>
			<td><input class="form-control" type="text" id="name" name="name" value="${(organ.name)!''}"/>
				<input class="form-control" type="hidden" id="code" name="code" value="${(organ.code)!''}" />
				<input  type="hidden" name="details.code" value="${(organ.details.code)!''}" />
			</td>
		</tr>
		<tr>
			<td class="table-left">简称</td>
			<td><input class="form-control" type="text" id="abbname" name="abbname" value="${(organ.abbname)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">网址</td>
			<td><input class="form-control" type="text" id="site" name="details.site" value="${(organ.details.site)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">电话</td>
			<td><input class="form-control" type="text" id="phone" name="details.phone" value="${(organ.details.phone)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">传真</td>
			<td><input class="form-control" type="text" id="fax" name="details.fax" value="${(organ.details.fax)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">Email</td>
			<td><input class="form-control" type="text" id="email" name="details.email" value="${(organ.details.email)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">地址</td>
			<td><input class="form-control" type="text" id="address" name="details.address" value="${(organ.details.address)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">邮编</td>
			<td><input class="form-control" type="text" id="postal" name="details.postal" value="${(organ.details.postal)!''}" style="width:80px;" /></td>
		</tr>
		<tr>
			<td class="table-left">负责人</td>
			<td><input class="form-control" type="text" id="manager" name="manager" value="${(organ.manager)!''}"/></td>
		</tr>
		<tr>
			<td class="table-left">机构类型</td>
			<td><#if (organ?? && '' != organ.pc)>
					<#if (organ.pc?? && '0' != organ.pc)>
						<@mte.OrganType value=((organ.otc)!"") id='otc' name='otc' pc=((organ.otc)!'')/>
					<#else>
						${(organ.otn)!''}
					</#if>
				<#else>
					<@mte.OrganType value=((organ.otc)!"") id='otc' name='otc' pc=((organ.otc)!'')/>
				</#if>
			</td>
		</tr>
		<tr>
			<td class="table-left">是否屏蔽</td>
			<td><@mt.YesOrNo value=((organ.deleted)!false) r=true name='deleted' d=false mc=false /></td>
		</tr>
		<tr>
			<td>是否使用</td>
			<td><@mt.YesOrNo value=((organ.isUsing)!false) r=true name='isUsing' d=false mc=false /></td>
		</tr>
		<tr>
			<td colspan="2" style="text-align: center; height:30px;">
				<a class="btn btn-info" href="javascript:;" onclick="javascript:saveOrgan_organ();"><i class="fontello-icon-floppy"></i> 保 存</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-info" href="javascript:;" onclick="javascript:sys_load_handle('organ');"><i class="fontello-icon-block"></i> 取 消</a>
			</td>
		</tr>
	</table>
</form>
